<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html lang="en">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="fly,layui,前端社区">
    <meta name="description" content="Fly社区是经典模块化前端框架 layui 的官方社区，平台致力于为 layui 开发者提供技术解答、分享、讨论等各类服务。">
    <!-- 		<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
    <!-- 		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> -->
    <base href="<%=basePath %>"/>
    <title>Fly - layui 前端框架官方社区</title>
    <link rel="stylesheet" type="text/css" href="../commons/iconfont/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../commons/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../style/global.css"/>
    <link rel="stylesheet" type="text/css" href="../style/sendPost.css"/>
    <script src="../js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../commons/layui/layui.js" type="text/javascript" charset="utf-8"></script>

    <style>
        .layui-layedit-tool .layui-icon {
            color: #009E94;
        }
    </style>
</head>
<body>
<div class="fly-header layui-bg-black">
    <div class="layui-container"><a class="fly-logo" name="headlink" href="javascript:gotoIndex();"> <img
            src="../img/logo.png"
            alt="layui">
    </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this"><a href="javascript:gotoIndex();"><i
                    class="iconfont icon-jiaoliu"></i>交流</a>
            </li>
            <li class="layui-nav-item"><a href="javascript:;"><i class="iconfont icon-chanpin"
                                                                 style="top: 1px;"></i>专区<span
                    class="layui-nav-more"></span></a>
                <dl class="layui-nav-child fly-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="/vipclub/list/layuiadmin/">layuiAdmin</a></dd>
                    <hr>
                    <dd><a href="/vipclub/list/layim/">LayIM</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="http://www.layui.com/"><i class="iconfont icon-ui"></i>框架</a></li>
            <c:if test="${!empty currentUser}">
                <li class="layui-nav-item nav-user"><a class="fly-nav-avatar" href="/user/" id="LAY_header_avatar">
                    <cite class="layui-hide-xs">${currentUser.nickName}</cite> <img
                        src="../upload/${currentUser.headImg}"><span class="layui-nav-more"></span></a>
                    <dl class="layui-nav-child layui-anim layui-anim-upbit">
                        <dd><a href="javascript:gotoUserCenter();">用户中心</a></dd>
                        <dd><a href="javascript:gotoUserAset();">基本设置</a></dd>
                        <hr>
                        <dd><a href="javascript:gotoUserMsg();">我的消息</a></dd>
                        <dd><a href="/user/product/">已购产品</a></dd>
                        <dd><a href="javascript:gotoUserHomepage();">我的主页</a></dd>
                        <hr style="margin: 5px 0;">
                        <dd><a href="javascript:logOut();" style="text-align: center;">退出</a></dd>
                    </dl>
                </li>
            </c:if>
        </ul>
        <c:if test="${empty currentUser}">
            <ul class="layui-nav fly-nav-user">
                <li class="layui-nav-item"><a class="iconfont icon-touxiang layui-hide-xs"
                                              href="https://fly.layui.com/user/login/"></a>
                </li>
                <li class="layui-nav-item"><a href="../page/login-register.jsp">登入</a></li>
                <li class="layui-nav-item"><a href="../page/login-register.jsp">注册</a></li>
                <li class="layui-nav-item layui-hide-xs"><a href="https://fly.layui.com/app/qq/"
                                                            onclick="layer.msg('&#39;正在通过QQ登入&#39;, {icon:16, shade: 0.1, time:0}')"
                                                            title="QQ登入" class="iconfont icon-qq"></a></li>
                <li class="layui-nav-item layui-hide-xs"><a href="https://fly.layui.com/app/weibo/"
                                                            onclick="layer.msg('&#39;正在通过微博登入&#39;, {icon:16, shade: 0.1, time:0}')"
                                                            title="微博登入" class="iconfont icon-weibo"></a></li>
            </ul>
        </c:if>
    </div>
</div>

<!-- 发表新帖 -->
<div class="layui-container">
    <div class="lay-tabs">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">发表新帖</li>
            </ul>
            <div class="layui-tab-content layui-show">
                <form action="" class="layui-form layui-form-pane" method="">
                    <div class="layui-row">
                        <div class="layui-form-item">
                            <input name="userId" type="hidden" value="${currentUser.id}">
                            <label class="layui-form-label">所在专栏</label>
                            <div class="layui-input-inline" pane>
                                <select name="column" lay-verify="required" lay-filter="column">
                                    <option value=""></option>
                                    <option value="1">提问</option>
                                    <option value="2">分享</option>
                                    <option value="3">讨论</option>
                                    <option value="4">建议</option>
                                </select>
                            </div>
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-inline title-width" pane>
                                <input name="title" type="text" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item layui-hide">
                            <label class="layui-form-label">所属产品</label>
                            <div class="layui-input-inline" pane>
                                <select name="" lay-verify="">
                                    <option value=""></option>
                                    <option value="010">layui</option>
                                    <option value="021">layuiAdmin</option>
                                    <option value="0571">layim</option>
                                    <option value="0571">模板市场</option>
                                    <option value="0571">扩展组件</option>
                                </select>
                            </div>
                            <label class="layui-form-label">版本</label>
                            <div class="layui-input-inline" pane>
                                <input type="text" class="layui-input"/>
                            </div>
                            <label class="layui-form-label">浏览器</label>
                            <div class="layui-input-inline browser-width" pane>
                                <input type="text" placeholder="浏览器名称及版本,如: IE11" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <textarea id="content" name="context" placeholder="详细描述" style="display: none;"></textarea>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">悬赏</label>
                            <div class="layui-input-inline" pane>
                                <select name="kiss" lay-verify="">
                                    <option value="20">20飞吻</option>
                                    <option value="50">50飞吻</option>
                                    <option value="80">80飞吻</option>
                                    <option value="100">100飞吻</option>
                                    <option value="500">500飞吻</option>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">发表后无法更改飞吻 <a class="tip" href="">(提升飞吻)</a></div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">图形码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="imgCode" required lay-verify="required" autocomplete="off"
                                       class="layui-input verifyCode">
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                <img class="code verifyCodeImg" src="verifyCodeImg"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button type="button" class="layui-btn" lay-submit lay-filter="send">立即发布</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="fly-footer">
    <p><a href="http://fly.layui.com/">Fly 社区</a> 2019 © <a href="http://www.layui.com/">layui.com</a></p>
    <p><a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a> <a href="https://fly.layui.com/extend/"
                                                                            target="_blank">组件平台</a>
        <a href="https://fly.layui.com/store/" target="_blank">模板市场</a> <a href="https://fly.layui.com/case/2019/"
                                                                           target="_blank">年度案例</a>
        <a href="http://fly.layui.com/jie/2461/" target="_blank">公众号</a></p>
    <div class="fly-union">
        <p style="display: block; margin-bottom: 10px;"><span>感谢以下平台提供云加速支持</span></p>
        <p><a href="https://console.upyun.com/register/?invite=SJ0wu6g2-" target="_blank" rel="nofollow"
              sponsor="upyun">
            <img src="../img/upyun.png"> </a> <a href="https://www.maoyuncloud.com/?from=layui" target="_blank"
                                                 rel="nofollow"
                                                 sponsor="maoyun"> <img src="../img/168_1559291577683_9348.png"> </a>
        </p>
    </div>
</div>
<script src="../js/index.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['layedit', 'form', 'jquery'], function () {
        var layedit = layui.layedit,
            form = layui.form,
            $ = layui.jquery;
        layedit.build('content', {
            height: 240, //编辑器的初始高度
            uploadImage: {
                url: '/upload/',
                type: 'post'
            } //上传图片的接口
        });
        //切换验证码
        $(".verifyCodeImg,.loginImgCode").click(function () {
            $(this).attr("src", "verifyCodeImg?ran=" + Math.random());
        });

        //发布帖子
        form.on('submit(send)', function (res) {
            //验证码校验
            $.post('../user/checkCodeImg', {verifyCode: res.field.imgCode}, function (data) {
                if (data.code === 1) {
                    layer.msg(data.msg);
                    $(".loginImgCode").attr("src", "verifyCodeImg?ran=" + Math.random());
                    return;
                }

                //发布
                let context = document.getElementById("LAY_layedit_1").contentDocument.body.innerHTML;
                res.field.context = context;
                $.post('../index/sendPost', res.field, function (result) {
                    if (result.code === 1) {
                        layer.msg(result.msg);
                        $(".loginImgCode").attr("src", "verifyCodeImg?ran=" + Math.random());
                        return;
                    }
                    gotoIndex();
                });
            })
        });

        form.on('select(column)', function (data) {
            let columnId = data.elem[data.elem.selectedIndex].value;
            columnId == 1 ? $(".layui-hide").removeClass("layui-hide") : $(".layui-form-item").eq(1).addClass("layui-hide");
        });
    });
</script>
<script src="../js/index.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>


